﻿using SQLite;
using System;
using System.Collections.Generic;
using System.Text;

namespace StockTradTest.Data
{
    public class Index : IComparable<Index>
    {
        [PrimaryKey, AutoIncrement]
        #region 属性
        public int ID { get; set; }
        public int Date { get; set; }
        public double OpenPrice { get; set; }
        public double ClosePrice { get; set; }
        public double ChangePrice { get; set; }
        public double ChangeRatio { get; set; }
        public double LowPrice { get; set; }
        public double HighPrice { get; set; }
        public int TotalHand { get; set; }
        public double TotalAmount { get; set; }
        public double HandRate { get; set; }
        #endregion
        public static readonly Dictionary<string, string> IndexDic = new Dictionary<string, string>()
        {
            {"000001","上证指数" },{ "000002","A股指数"},{"000003","B股指数" }, { "000004","工业指数"},
            {"000005","商业指数" },{ "000006","地产指数"},{"000007","公用指数"}, { "000008","综合指数" },
            {"399001","深证成指" },{ "399002","深成指R"},{"399003","成份B指" },{ "000300","沪深300"},
            {"000903","中证100" }, { "000905","中证500"},{"000906","中证800" },{ "399007","深证300"},
            {"399008","中小300" }, { "399101","中小板综"},{"399106","深证综指" },{ "399107","深证A指"},
            {"399108","深证B指" }, { "399300","沪深300T"}
        };
        public int CompareTo(Index other)
        {
            if (null == other)
            {
                return 0;//空值比较大，返回1
            }
            return this.Date.CompareTo(other.Date);//升序
            //return other.Date.CompareTo(this.Date);//降序
        }
        public string Info()
        {
            string text = string.Format("ID:{0}\n" +
                "日期:{1}\n" +
                "开盘:{2}\n" +
                "收盘:{3}\n" +
                "最高:{4}\n" +
                "最低:{5}\n" +
                "涨跌:{6}\n" +
                "涨跌幅:{7}\n" +
                "手数:{8}\n" +
                "换手率:{9}%\n" +
                "成交额:{10}\n",
                ID,
                Date.ToString(),
                OpenPrice,
                ClosePrice,
                HighPrice,
                LowPrice,
                ChangePrice,
                ChangeRatio,
                TotalHand,
                HandRate,
                TotalAmount);
            return text;
        }
    }
}
